<template>
<div>

  <div style="margin: 10px 0;">
    <el-button type="primary" @click="add">新增</el-button>
    <el-button type="primary">导入</el-button>
    <el-button type="primary">导出</el-button>
  </div>
  <!--    搜索区域-->
  <div style="margin: 10px 0">
    <el-input v-model="search" placeholder="输入关键字" style="width: 20%" clearable></el-input><!--clearable清空按钮-->
    <el-button type="primary" style="margin-left: 5px" @click="load">查询</el-button>
  </div>


  <el-table
      :data="tableData"
      border
      style="width: 100%">
    <el-table-column
        fixed
        prop="id"
        label="ID"
        width="150">
    </el-table-column>
    <el-table-column
        prop="title"
        label="标题"
        width="120">
    </el-table-column>
    <el-table-column
        prop="link"
        label="跳转链接"
        width="120">
    </el-table-column>
    <el-table-column
        prop="cover"
        label="图片"
        width="120">
    </el-table-column>
    <el-table-column
        prop="ordered"
        label="顺序"
        width="300">
    </el-table-column>
    <el-table-column
        prop="summary"
        label="详情"
        width="120">
    </el-table-column>
    <el-table-column  label="操作"  >
      <template #default="scope">
        <el-button link type="primary" size="small">查看</el-button>
        <el-button @click="handleEdit(scope.row)" link type="primary" size="small">编辑</el-button>
        <el-popconfirm title="确认删除吗?" @confirm="handleDelete(scope.row.id)">
          <template #reference>
            <el-button link size="small" style="color: red">删除</el-button>
          </template>
        </el-popconfirm>
      </template>
    </el-table-column>
  </el-table>



  <div style="margin: 10px 0">

    <!--分页-->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400">
    </el-pagination>

    <!--弹出新增对话框，通过变量dialogVisible来控制弹窗的开启或关闭-->
    <!--v-model用于绑定对象-->
    <el-dialog title="提示" v-model="dialogVisible" width="30%">
      <!--新增表单-->
      <el-form :model="form" label-width="120px">
        <!--表单项-->
        <el-form-item label="用户名">
          <el-input v-model="form.username" style="width: 80%"></el-input>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input v-model="form.nickName" style="width: 80%"></el-input>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input v-model="form.age" style="width: 80%"></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-radio v-model="form.sex" label="男">男</el-radio>
          <el-radio v-model="form.sex" label="女">女</el-radio>
          <el-radio v-model="form.sex" label="隐私">隐私</el-radio>
          <!--            <el-input v-model="form.sex" style="width: 80%"></el-input>-->
        </el-form-item>
        <el-form-item label="地址">
          <el-input type="textarea" v-model="form.address" style="width: 80%"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
          <span class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="save">确 定</el-button>
        </span>
      </template>
    </el-dialog>
  </div>

</div>
</template>

<script>
export default {
  name: "Banner",

  data() {
    return {
      form: {},
      dialogVisible: false,

      tableData: [

          //伪数据
        {
          id: 1,
          title: "zhansan",
          link: "www.baidu.com",
          cover: "一张图片",
          ordered: 1,
          summary: "12345567686"
        }
      ]
    }
  },
  methods: {
    add() {//新增方法，弹窗中新增，这里可以打开弹窗
      this.dialogVisible = true
      this.form = {} //清空表单
    },
  }
}
</script>

<style scoped>

</style>